<template>
  <div id="categories">
    <c-title text="全部分类"></c-title>
    <div class="classify-header">
      <div class="classify-search flex-a-c flex-j-sb">
        <div class="search-left" @click="searchOn">
          <input placeholder="" v-model="query.title" />
          <div class="iconfont icon-sousuo1"></div>
          <div class="search-btn">搜索</div>
        </div>
        <div class="right">
          <div class="service flex-a-c flex-j-c" @click="showService">
            <div class="iconfont icon-custom-service"></div>
          </div>
        </div>
      </div>
      <div class="classify-tab">
        <van-tabs v-model="active" @click="firstOn" swipeable>
          <block v-for="(item, index) in stairClassify" :key="index">
            <van-tab :title="item.name" :name="item.id"></van-tab>
          </block>
        </van-tabs>
      </div>
    </div>
    <!-- <div class="secondary flex"> //#10975 优化周边游样式
      <ul class="flex-a-c">
        <li v-for="(item, index) in secondary" :key="index" :class="secondaryIndex === index ? 'on' : ''" class="secondary-item" @click="secondaryOn(index)">{{ item.name }}</li>
      </ul>
    </div> -->
    <div class="classify-goodsList">
      <div class="search-goods flex-j-sb" v-if="categoriesGoodsList.length > 0">
        <block :key="index" v-for="(item, index) in categoriesGoodsList">
          <div class="goods-item flex" @click="goodsNavTo(item.id)">
            <div class="goods-img">
              <img :src="item.thumb" />
              <div class="volume">已售 {{ item.show_sales }}</div>
            </div>
            <div class="goods-name flex-a-c">
              <div class="goods-title">
                {{ item.title }}
              </div>
              <div class="long-title">{{item.long_title}}</div>
            </div>
            <div class="fine-food flex-a-c">
              <div class="fine"><span>￥</span>{{ item.price }}</div>
              <div class="number">￥{{ item.market_price }}</div>
            </div>
          </div>
        </block>
      </div>
      <van-empty description="空空如也" v-else-if="goodsFlag && categoriesGoodsList.length === 0" />
      <van-empty description="加载中" v-else />
    </div>
    <yz-service v-model="serviceShow" :url="cservice" :mobile="serviceMobile" :qr="serviceQRcode"></yz-service>
  </div>
</template>
<script>
import categories_controller from "./categories_controller";
export default categories_controller;
</script>
<style scoped>
#categories ::v-deep .van-tabs {
  border-radius: 0.3125rem;
}

#categories ::v-deep .van-tab--active .van-tab__text {
  color: var(--themeBaseColor);
}

#categories ::v-deep .van-tabs--line .van-tabs__wrap {
  border-radius: 0.3125rem;
}

#categories ::v-deep .van-nav-bar {
  background-color: var(--themeBaseColor);
  border: none;
}

#categories ::v-deep .van-tabs__line {
  background-color: var(--themeBaseColor);
}

#categories ::v-deep .van-nav-bar__left .van-button {
  background-color: var(--themeBgColor);
}

#categories ::v-deep .van-nav-bar .van-icon {
  color: #fff;
}

#categories ::v-deep .van-nav-bar__title {
  color: #fff;
}

::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}
</style>
<style lang="scss" scoped>
::v-deep .van-tabs__nav {
  background-color: transparent;
}

.classify-header {
  padding: 0.5rem 0 0 0;
  background-image: linear-gradient(#ffc11e, #f5f5f5);
  background-image: var(--themeBgColor);

  .classify-tab {
    margin: 0 0.625rem 0.875rem 0.625rem;
  }
}

.classify-search {
  position: relative;
  margin: 0 0.9375rem 0 1.0625rem;

  .search-left {
    position: relative;

    input {
      width: 16.875rem;
      padding-left: 2.5rem;
      height: 1.875rem;
      background: #fff;
      border: 0.0625rem solid #fff;
      border-radius: 0.9375rem;
      position: relative;
    }

    .search-btn {
      font-size: 0.6875rem;
      font-weight: 400;
      color: #fff;
      padding: 0.3125rem 0.75rem;
      border-radius: 0.75rem;
      background-color: var(--themeBaseColor);
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      right: 0.25rem;
    }

    .icon-sousuo1 {
      color: var(--themeBaseColor);
      position: absolute;
      top: 0.375rem;
      left: 1rem;
    }
  }

  .service {
    width: 2.1875rem;
    height: 1.5625rem;
    background-color: #ffedbd;
    border-radius: 10px;

    .icon-custom-service {
      line-height: 0.875rem;
      font-size: 0.875rem;
    }
  }
}

.secondary {
  margin: 0 0.625rem;

  ul {
    width: 100%;
    overflow-x: scroll;
  }

  .secondary-item {
    font-size: 0.75rem;
    margin-right: 1.375rem;
    font-weight: 400;
    color: #666;
    white-space: nowrap;
    // margin-right: 1.6875rem;
  }

  .on {
    font-size: 0.75rem;
    line-height: 0.75rem;
    color: #fff;
    padding: 0.4375rem 0.5625rem 0.375rem 0.4375rem;
    border-radius: 0.6875rem;
    background-color: var(--themeBaseColor);
  }
}

.classify-goodsList {
  margin: 0.875rem 0 0 0;
}

/* 商品信息 */
.search-goods {
  flex-wrap: wrap;
  margin: 0 0.625rem;
}

.goods-item {
  width: 10.7813rem;
  background-color: #fff;
  border-radius: 0.9375rem;
  flex-direction: column;
  padding: 0 0 0.625rem 0;
  margin-bottom: 0.625rem;

  .goods-img {
    width: 10.7813rem;
    height: 10.7813rem;
    border-radius: 0.4688rem 0.4688rem 0 0;
    position: relative;

    img {
      width: 100%;
      right: 0;
      height: 100%;
      position: absolute;
      border-top-left-radius: 0.5rem;
      border-top-right-radius: 0.5rem;
    }
  }

  .volume {
    width: 100%;
    box-sizing: border-box;
    position: absolute;
    bottom: 0;
    left: 0;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 0.5rem 0.6875rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 400;
    color: #fff;
  }

  .goods-name {
    margin: 0 0.625rem 0 0.5rem;
    flex-direction: column;
    display: flex;
    align-items: flex-start;

    .goods-title {
      font-size: 0.95rem;
      font-weight: bold;
      color: #35314a;
      text-align: left;
    }

    .long-title {
      font-size: 0.85rem;
      color: #818181;
      margin: 0.2rem 0;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-line-clamp: 1;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      text-align: left;
    }
  }

  .fine-food {
    margin: 0 0.625rem 0 0.5rem;

    .fine {
      font-size: 0.9375rem;
      font-weight: 500;
      color: #ff3a00;
      margin-right: 0.5rem;

      span {
        font-size: 0.6875rem;
      }
    }

    .number {
      font-size: 0.75rem;
      font-weight: 500;
      color: #686868;
    }
  }
}
</style>
